package com.cssl.service.impl;


import com.cssl.domain.DtsPermission;
import com.cssl.domain.DtsRole;
import com.cssl.service.DtsPermissionService;
import com.cssl.mapper.DtsPermissionMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashSet;
import java.util.Set;

/**
 * @author 黄鑫
 * @description 针对表【dts_permission(权限表)】的数据库操作Service实现
 * @createDate 2024-08-20 17:44:20
 */
@Service
public class DtsPermissionServiceImpl
        implements DtsPermissionService {
    @Autowired
    private DtsPermissionMapper mapper;

    @Override
    public boolean checkSuperPermission(Integer roleId) {
        if (roleId == null) {
            return false;
        }

        return mapper.checkSuperPermission(roleId) != 0;
    }

    @Override
    public Set<String> queryByRoleId(Integer roleId) {
        Set<String> permissions = new HashSet<String>();
        if (roleId == null) {
            return permissions;
        }
        for (DtsPermission permission : mapper.queryByRoleId(roleId)) {
            permissions.add(permission.getPermission());
        }

        return permissions;
    }

    @Override
    public int deletePermission(DtsRole role) {
        return mapper.deletePermission(role
        );
    }
}




